export function cardIdToUserInfo(IDCard: string) {
  // 提取性别
  const sex = parseInt(IDCard.charAt(16)) % 2 === 1 ? '男' : '女';

  // 提取出生日期
  const yearBirth = IDCard.substring(6, 10);
  const monthBirth = parseInt(IDCard.substring(10, 12));  // 将字符串转换为数字
  const dayBirth = parseInt(IDCard.substring(12, 14));    // 将字符串转换为数字
  const birthDate = `${yearBirth}-${monthBirth.toString().padStart(2, '0')}-${dayBirth.toString().padStart(2, '0')}`;

  // 计算年龄
  const currentDate = new Date();
  const currentYear = currentDate.getFullYear();
  const currentMonth = currentDate.getMonth() + 1; // 月份是从0开始的，所以加1
  const currentDay = currentDate.getDate();

  let age = currentYear - Number(yearBirth);  // 确保 yearBirth 为数字类型
  if (currentMonth < monthBirth || (currentMonth === monthBirth && currentDay < dayBirth)) {
    age--;
  }

  // 返回处理后的数据
  return {
    sex,
    birthDate,
    age,
  };
}
